define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'staff/job/index' + location.search,
                    add_url: 'staff/job/add',
                    edit_url: 'staff/job/edit',
                    del_url: 'staff/job/del',
                    multi_url: 'staff/job/multi',
                    import_url: 'staff/job/import',
                    table: 'staff_job',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'pid', title: __('Pid')},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'weigh', title: __('Weigh'), operate: false},
                        {field: 'status', title: __('Status'), searchList: {"30":__('Status 30')}, formatter: Table.api.formatter.status},
                        {field: 'staff.id', title: __('Staff.id')},
                        {field: 'staff.portraitimage', title: __('Staff.portraitimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'staff.type', title: __('Staff.type'), operate: 'LIKE'},
                        {field: 'staff.shop_id', title: __('Staff.shop_id')},
                        {field: 'staff.name', title: __('Staff.name'), operate: 'LIKE'},
                        {field: 'staff.sex', title: __('Staff.sex')},
                        {field: 'staff.nation', title: __('Staff.nation'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.idcard', title: __('Staff.idcard'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.mobile', title: __('Staff.mobile'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.datebirth', title: __('Staff.datebirth'), operate: 'LIKE'},
                        {field: 'staff.maritalstatus', title: __('Staff.maritalstatus')},
                        {field: 'staff.politicaloutlook', title: __('Staff.politicaloutlook'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.education', title: __('Staff.education'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.nativeplace', title: __('Staff.nativeplace'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.location', title: __('Staff.location'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.workingyears', title: __('Staff.workingyears'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.probationperiod', title: __('Staff.probationperiod'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.employmenttime', title: __('Staff.employmenttime'), operate: 'LIKE'},
                        {field: 'staff.siling', title: __('Staff.siling'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.confirmationtime', title: __('Staff.confirmationtime'), operate: 'LIKE'},
                        {field: 'staff.staffcode', title: __('Staff.staffcode'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.department', title: __('Staff.department'), operate: 'LIKE'},
                        {field: 'staff.position', title: __('Staff.position'), operate: 'LIKE'},
                        {field: 'staff.jobgrade', title: __('Staff.jobgrade'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.rank', title: __('Staff.rank'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'staff.createtime', title: __('Staff.createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'staff.updatetime', title: __('Staff.updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'staff.status', title: __('Staff.status')},
                        {field: 'staff.signingtime', title: __('Staff.signingtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'staff.expirationtime', title: __('Staff.expirationtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'staff.contractimage', title: __('Staff.contractimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'staff.numberofsignings', title: __('Staff.numberofsignings')},
                        {field: 'staff.p_name', title: __('Staff.p_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
